<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Account/classes/PhpFox_ComponentBlockedUsers.class.php, $Author:  $ */



/** Blocked users list
 * 
 * @package module.account
 * @version $Id: PhpFox_ComponentBlockedUsers.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 *   
 */
class PhpFox_Mod_Account_ComponentBlockedUsers extends BaseComponent
{

    /** Processing method
     */
	function process()
	{
	    $oAcc = $this->getParam('oUser');
	    assert(null != $oAcc);
	    
	    $oReq = &App::getRequest();
	    $oSrvBlock = $this->_oModule->getService('Block');
	    /* @var $oSrvBlock PhpFox_Mod_Account_ServiceBlock */

	    switch($oReq->getAction())
	    {
	        // ----- unblock user -----
	        case 'unblock':
	            $oSrvAcc = &App::getModuleService('Account', 'Account');
	            /* @var $oSrvAcc PhpFox_Mod_Account_ServiceAccount */
	            $oBlockedUser = &$oSrvAcc->getByUsername($oReq->get('name'));
	            $aMess = array();
	            if ($oBlockedUser)
	            {
	               if ($oSrvBlock->unblock($oAcc, $oBlockedUser))
	               {
	                   $aMess[] = App::format('Mod_Account.user_unblocked',
	                                          array($oBlockedUser->aData['user']));
	               }
	            }
	            $oUrl = &App::getUrl();
	            $oUrl->clearParams('act');
	            $oUrl->clearParams('name');
	            App::forward($oUrl->getUrl(), $aMess, App::getPageName(), 'BlockedUsers');
	            break;
	            
	    }
	    
	    $iPage = $oReq->getInt('page', 1);
    	$iPageSize = App::getParam('public.pagesize');
	    list($aBlockedUsers, $iTotal) = $oSrvBlock->getBlockedUsers($oAcc, $iPage, $iPageSize, '`time` DESC');
	    $oPager = App::newObject('Pager', $iTotal, $iPage, $iPageSize);

		$oTpl = &$this->_oModule->getTemplate();
		$oTpl->assign(array(
			'aBlockedUsers' => $aBlockedUsers,
			'sUserPicUrl'   => App::getParam('user.pic.url'),
	        'aPaging'       => $oPager->getInfo(App::getUrl()),
		));
		$srcHtml = $oTpl->fetch('BlockedUsers.html');
		return $srcHtml;
	}

}
?>